<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="application/javascript">
        if (!!window.EventSource) {
            var event = new EventSource("/serverPush");

            event.addEventListener('message', function(t) {
                var data = t.data;
                document.write(data+"<br/>")
            });

            event.addEventListener("open",function (t) {
                console.log("开启");
            },false);

            event.addEventListener("error",function (t) {
                if (t.readyState  == EventSource.CLOSED) {
                    console.log("关闭");
                }
            },false);



        }else{
            console.error("浏览器不支持");
        }


    </script>
</head>
<body>

</body>
</html>